package com.example.gradu.graduationproject.service.impl;

import com.example.gradu.graduationproject.domain.FansUser;
import com.example.gradu.graduationproject.mapper.FansUserMapper;
import com.example.gradu.graduationproject.service.FansUserService;
import com.example.gradu.graduationproject.util.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (FansUser)表服务实现类
 *
 * @author makejava
 * @since 2025-02-20 23:02:35
 */
@Service("fansUserService")
public class FansUserServiceImpl implements FansUserService {
    @Resource
    private FansUserMapper fansUserMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param fansid 主键
     * @return 实例对象
     */
    @Override
    public R queryById(Integer fansid) {
        return R.ok().setData(this.fansUserMapper.queryById(fansid));
    }

    /**
     * 全查询
     *
     * @param fansUser 筛选条件
     * @return 查询结果
     */
    @Override
    public R queryAll(FansUser fansUser) {
        return R.ok().setData(this.fansUserMapper.queryAll(fansUser));
    }

    /**
     * 新增数据
     *
     * @param fansUser 实例对象
     * @return 实例对象
     */
    @Override
    public R insert(FansUser fansUser) {
        this.fansUserMapper.insert(fansUser);
        return R.ok().setData(fansUser);
    }

    /**
     * 修改数据
     *
     * @param fansUser 实例对象
     * @return 实例对象
     */
    @Override
    public R update(FansUser fansUser) {
        this.fansUserMapper.update(fansUser);
        return R.ok().setData(this.queryById(fansUser.getFansid()));
    }

    /**
     * 通过主键删除数据
     *
     * @param fansid 主键
     * @return 是否成功
     */
    @Override
    public R deleteById(Integer fansid) {
        boolean del = this.fansUserMapper.deleteById(fansid) > 0;
        return R.ok().setData(del);
    }
}

